package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feign.order.OrderFeignClient;
import com.atguigu.gmall.order.vo.OrderConfirmRespVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Api(tags = "订单详情")
@Controller
public class OrderController {

    @Autowired
    OrderFeignClient orderFeignClient;

    @GetMapping("/trade.html")
    public String trade (Model model){
        //远程调用订单，获取订单确认数据
        OrderConfirmRespVo data = orderFeignClient.orderConfirmData().getData();
        //详情列表，购买了哪些 商品{skuId、imgUrl、skuName、orderPrice、skuNum}
        model.addAttribute("detailArrayList", data.getDetailArrayList());
        model.addAttribute("totalNum", data.getTotalNum());
        model.addAttribute("totalAmount", data.getTotalAmount());
        model.addAttribute("userAddressList", data.getUserAddressList());
        model.addAttribute("tradeNo", data.getTradeNo());
        return "order/trade";
    }

    @GetMapping("/myOrder.html")
    public String orderListPage(){

        //TODO 订单列表
        return "order/myOrder";
    }
}
